import sys
from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import Qt 
from ..widgets.image_button import ImageButton


s = ""

class LabelPair(QtGui.QWidget):
	def __init__(self, parent, cap, val, *args, **kw):
		QtGui.QWidget.__init__(self, parent, *args, **kw)
		self.setGeometry(0, 0, 200, 20)

		#font = QtGui.QFont("Gabrielle", 14)
		font = QtGui.QFont("Serif", 12)

		caption = QtGui.QLabel(self)
		caption.setGeometry(0, 0, 100, 20)
		caption.setText(cap)
		caption.setFont(font)

		v = QtGui.QLabel(self)
		v.setGeometry(110, 0, 90, 20)
		s = ": {}".format(val)
		v.setText(s)
		v.setFont(font)
		self.value = v

	def set(self, value):
		buff = ": {}".format(value)
		self.value.setText(buff)

class SlaveStatPanel(QtGui.QWidget):
	def __init__(self, *args, **kw):
		QtGui.QWidget.__init__(self, *args, **kw)
		self.setGeometry(0, 0, 242, 431)

		self.state = 0

		self.pic = QtGui.QLabel(self)
		path = "resources/slave_info_panel.png"
		self.pic.setGeometry(0, 0, 242, 431)
		self.pic.setPixmap(QtGui.QPixmap(path))

		font = QtGui.QFont("Gabrielle", 18)
		self.title = QtGui.QLabel(self)
		self.title.setGeometry(32, 4, 180, 24)
		self.title.setText("Samantha")
		self.title.setFont(font)
		self.title.setAlignment(Qt.AlignHCenter|Qt.AlignHCenter)

		self.more = ImageButton("more", self,
			"resources/more_info_norm.png",
			"resources/more_info_hover.png",
			"resources/more_info_down.png",
			"resources/more_info_norm.png",
		)
		self.more.setGeometry((242 - 74) / 2, 380, 75, 34)
		self.more.clicked.connect(self.more_click)

		self.sam = Camel()

		self.frame_1 = self.mk_frame1(self.sam)
		self.frame_1.show()
		self.frame_2 = self.mk_frame2(self.sam)
		self.frame_2.hide()

	def set_title_text(self, name):
		self.title.setText(name)

	def more_click(self):
		if self.state == 0:
			self.frame_1.hide()
			self.frame_2.show()
			self.state = 1
		else:
			self.frame_1.show()
			self.frame_2.hide()
			self.state = 0



	def mk_frame1(self, girl):
		print "making frame one"
		f = QtGui.QFrame(self)
		f.setGeometry(20, 40, 213, 335)

		inc = 24
		xoff = 10
		yoff = 10
		self.age = LabelPair(f, "Age", girl.age)
		self.age.move(xoff, yoff)

		yoff += inc
		self.level = LabelPair(f, "Level", girl.level)
		self.level.move(xoff, yoff)

		yoff += inc
		self.fee = LabelPair(f, "Fee", girl.ask_price)
		self.fee.move(xoff, yoff)

		yoff += inc
		self.price = LabelPair(f, "Price", girl.sale_price)
		self.price.move(xoff, yoff)

		yoff += inc
		self.beauty = LabelPair(f, "Beauty", girl.beauty)
		self.beauty.move(xoff, yoff)

		yoff += inc
		self.charisma = LabelPair(f, "Charsima", girl.charisma)
		self.charisma.move(xoff, yoff)

		yoff += inc
		self.obedience = LabelPair(f, "Obedience", girl.obedience)
		self.obedience.move(xoff, yoff)

		yoff += inc
		self.happiness = LabelPair(f, "Happiness", girl.happiness)
		self.happiness.move(xoff, yoff)

		yoff += inc
		self.intelligence = LabelPair(f,
			"Intelligence", girl.intelligence
		)
		self.intelligence.move(xoff, yoff)

		yoff += inc
		self.agility = LabelPair(f, "Agility", girl.agility)
		self.agility.move(xoff, yoff)

		yoff += inc
		self.virgin = LabelPair(f, "Virgin", "No")
		self.virgin.move(xoff, yoff)

		yoff += inc
		self.slave = LabelPair(f, "Slave", "Yes")
		self.slave.move(xoff, yoff)

		return f

	def mk_frame2(self, girl):
		f = QtGui.QFrame(self)
		f.setGeometry(20, 40, 213, 335)

		inc = 24
		xoff = 10
		yoff = 10
		self.combat = LabelPair(f, "Combat", girl.combat)
		self.combat.move(xoff, yoff)

		yoff += inc
		self.tech = LabelPair(f, "Technical", girl.tech)
		self.tech.move(xoff, yoff)

		yoff += inc
		self.magic = LabelPair(f, "Magic", girl.magic)
		self.magic.move(xoff, yoff)

		yoff += inc
		self.sex = LabelPair(f, "Sex", girl.normal_sex)
		self.sex.move(xoff, yoff)

		yoff += inc
		self.oral = LabelPair(f, "Oral", girl.oral)
		self.oral.move(xoff, yoff)

		yoff += inc
		self.anal = LabelPair(f, "Anal", girl.anal)
		self.anal.move(xoff, yoff)

		yoff += inc
		self.bondage = LabelPair(f, "Bondage", girl.bdsm)
		self.bondage.move(xoff, yoff)

		yoff += inc
		self.bestiality = LabelPair(f, "Bestiality", girl.bestiality)
		self.bestiality.move(xoff, yoff)

		yoff += inc
		self.lesbian = LabelPair(f, "Lesbian", girl.lesbian)
		self.lesbian.move(xoff, yoff)

		yoff += inc
		self.service = LabelPair(f, "Service", girl.service)
		self.service.move(xoff, yoff)

		yoff += inc
		self.stripping = LabelPair(f, "Stripping", girl.strip)
		self.stripping.move(xoff, yoff)

		return f

	def camel(self):
		self.update(self.sam)

	def update(self, girl):
		self.set_title_text(girl.name)
		self.age.set(girl.age)
		self.level.set(girl.level)
		print "displaying fee as : ", girl.ask_price
		self.fee.set(girl.ask_price)
		print "displaying price as : ", girl.sale_price
		self.price.set(girl.sale_price)
		self.beauty.set(girl.beauty)
		self.charisma.set(girl.charisma)
		self.obedience.set(girl.obedience)
		self.happiness.set(girl.happiness)
		self.intelligence.set(girl.intelligence)
		self.agility.set(girl.agility)
		self.combat.set(girl.combat)
		self.tech.set(girl.tech)
		self.magic.set(girl.magic)
		self.sex.set(girl.normal_sex)
		self.oral.set(girl.oral)
		self.anal.set(girl.anal)
		self.bondage.set(girl.bdsm)
		self.bestiality.set(girl.bestiality)
		self.lesbian.set(girl.lesbian)
		self.service.set(girl.service)
		self.stripping.set(girl.strip)


class Camel(object):
	def __init__(self, *args, **kw):
		object.__init__(self)
		self.name = "Samantha"
		self.age = 18
		self.level = 1
		self.ask_price = 24
		self.sale_price = 1200
		self.beauty = 70
		self.charisma = 40
		self.obedience = 10
		self.happiness = 90
		self.intelligence = 50
		self.agility = 30
		self.combat = 75
		self.tech = 0
		self.magic = 10
		self.normal_sex = 10
		self.oral = 0
		self.anal = 50
		self.bdsm = 10
		self.bestiality = 90
		self.lesbian = 0
		self.service = 0
		self.strip = 0
		self.virgin = False
	def calc_prices(self):
		pass

if __name__ == "__main__":

	app = QtGui.QApplication(sys.argv)

	font_db = QtGui.QFontDatabase()
	font_db.addApplicationFont("resources/Gabrielle.ttf")
	font_db.addApplicationFont("resources/mark.ttf")

	top = QtGui.QLabel()
	path = "resources/wood.jpg"
	top.setGeometry(0, 0, 1024, 768)
	top.setPixmap(QtGui.QPixmap(path))

	panel = SlaveStatPanel(top)
	panel.move(20, 20)

	top.show()
	sys.exit(app.exec_())

